<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
    <style>
      p {
        height: 300px;
        border: solid;
        font-size: 3rem;
      }
    </style>
  </head>
  <body>
    <div id="box">
      <p>p1</p>
      <p>p2</p>
      <p>p3</p>
      <p>p4</p>
      <p>p5</p>
      <p>p6</p>
      <p>p7</p>
      <p>p8</p>
    </div>
    <script>
      window.onscroll = function () {
        // 判断是否触底
        const dis =
          document.documentElement.scrollHeight -
          window.innerHeight -
          window.pageYOffset;
        // 触底
        if (dis <= 60) {
          // 创建新内容
          const newP = document.createElement("p");
          newP.innerHTML = "new P";
          box.append(newP);
          //   const newP = box.insertAdjacentHTML("afterEnd", "<p>new P</p>");
        }
      };
    </script>
  </body>
</html>
